﻿#region Creditos

/* Autor: Edilberto Sánchez Forero	*/
/* Email: esanchezfo@gmail.com		*/
/* Licencia: LGPL, Software Libre	*/
/* País: Colombia, Bogotá			*/

#endregion

#region Librerias

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

using ESF.General;

#endregion


namespace ESF.Object.XmlRepresenter.Extensions.Description
{
	public class XmlObjectDescription :  IEquatable<XmlObjectDescription>
	{
		#region Miembros
		
		private string _ObjectName;
		private string _Label;
		private string _Description;	
		private string _ISOLanguageCode;
		
		private bool _Default;
		
		#endregion
		
		
		#region Propiedades
		
		public string ObjectName { get { return this._ObjectName; } }
		
		public string Label { get { return this._Label; } }
		
		public string Description { get { return this._Description; } }
		
		public string ISOLanguageCode { get { return this._ISOLanguageCode; } }
		
		public bool Default { get {return this._Default; } }
		
		#endregion
		
		
		#region Constructor
		
		internal XmlObjectDescription (string pstrObjectName)
		{
			this._ObjectName = pstrObjectName;
			this._Label = pstrObjectName;
			this._Description = pstrObjectName;
			this._ISOLanguageCode = "en";
			this._Default = true;
		}
		
		
		public XmlObjectDescription (ref XmlTextReader pxmlReader, bool pblnDefault, string pstrISOLanguageCode)
		{
			XmlHelper xmlEx;
			
		
			xmlEx = new XmlHelper ();
			xmlEx.ObjectName = "Descripción del Objeto " + pxmlReader.Name;
			xmlEx.EvaluatedNodeReader = pxmlReader;
			
			this._ObjectName = pxmlReader.Name;
			
			this._ISOLanguageCode = pstrISOLanguageCode;
			
			this._Label = xmlEx.GetAttributeValue (false, "label", "Etiqueta"); 
			
			if (string.IsNullOrEmpty (this._Label))
			{
				this._Label = pxmlReader.Name;
			}
			
			this._Description = xmlEx.GetAttributeValue (false, "description", "Descripción");
			
			this._Default = pblnDefault;
		}
		
		#endregion


		#region IEquatable<XmlObjectDescription> Members

		public bool Equals (XmlObjectDescription pobjOtherDescription)
		{
			return (pobjOtherDescription.ISOLanguageCode == this.ISOLanguageCode && pobjOtherDescription.ObjectName == this.ObjectName);
		}

		#endregion
	}
}